package org.vy.app.ajax.service.metadata;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.vy.app.ajax.IService;
import org.vy.dal.dao.lookup.VyLookupProfessionDAO;
import org.vy.dal.dao.lookup.VyLookupProfessionDO;

public class ProfessionMetaService implements IService<ProfessionMetaResponse> {

	@Override
	public ProfessionMetaResponse execute(Map<String, String> params, HttpServletRequest request) {
		ProfessionMetaResponse rsp = new ProfessionMetaResponse();
		try{
			VyLookupProfessionDO dto = new VyLookupProfessionDO();
			dto.setProfessionCode("%");
			List<VyLookupProfessionDO> professions = VyLookupProfessionDAO.findByParam(dto);
			rsp.setProfession(getProfessionMap(professions));
		}catch(Exception e){
			e.printStackTrace();
		}
		return rsp;
	}
	
	private Map<String, String> getProfessionMap(List<VyLookupProfessionDO> lst){
		Map<String, String> map = new HashMap<String, String>();
		for(VyLookupProfessionDO rec : lst){
			map.put(rec.getProfessionName(),rec.getProfessionCode());
		}
		return map;
	}
}
